package com.sxfq.loansupermarket.backsystem.modular.theTest.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.core.shiro.ShiroKit;
import com.sxfq.loansupermarket.backsystem.core.shiro.ShiroUser;
import com.sxfq.loansupermarket.backsystem.core.support.DateTimeKit;
import com.sxfq.loansupermarket.backsystem.core.util.StringUtil;
import com.sxfq.loansupermarket.backsystem.modular.base.SqlMapper;
import com.sxfq.loansupermarket.backsystem.modular.theTest.dao.AchievementsDao;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.AchievementsInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.SearchAchievementsInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.TheTestInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.service.IAchievementsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据统计Dao
 *
 * @author fengshuonan
 * @Date 2017-07-19 16:23:35
 */
@Service
public class AchievementsInfoServiceImpl implements IAchievementsInfoService {

    @Autowired
    private AchievementsDao dao;

    @Autowired
    private SqlMapper sqlMapper;

    @Override
    public void UpdateWithInfo(AchievementsInfo entity) throws Exception {
        String sql="update user_for_test_info set remark= '" + entity.getRemark() + "' where id= '" + entity.getId() + "'";
        sqlMapper.update(sql);
    }
    public AchievementsInfo selectOneById(String userForTestInfoId) throws Exception {
        String sql = "select * from user_for_test_info where id= '" + userForTestInfoId + "'";
        AchievementsInfo achievementsInfo=sqlMapper.selectOne(sql, AchievementsInfo.class);
        return achievementsInfo;
    }
    @Override
    public List<AchievementsInfo> selectPageListByQueryGetMap(Page<AchievementsInfo> page, SearchAchievementsInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getTheTestName())) {
            params.put("theTestName", searchInfo.getTheTestName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getUserName())) {
            params.put("userName", searchInfo.getUserName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getQueryPage(page, params);
    }


}
